<?php  if ( ! defined('IN_DiliCMS')) exit('No direct script access allowed');
	class Category_m extends CI_Model{
		function __construct()
		{
			parent::__construct();
		}
		function get_subclass($parentid=0)	//获取子类列表，用于侧边导航
		{
			if($parentid==0){
				$sql="select  classname,classid from  dili_u_c_trav_lines where level=2  and parentid=1";
			}else{
				$sql="select classname,classid from  dili_u_c_trav_lines where level=2 and parentid=".$parentid;
			}
			$subclass=$this->db->query($sql)->result();
			return $subclass;
		}
		function get_category_list($cateid=0,$lineclass_p)	//获取一级类旅游线路列表
		{
			if((int)$cateid && $lineclass_p){
				foreach($lineclass_p as $key=>$value){
					$sql="select id,TravelTime,trav_title,price_per,departure_date,tuijian from  dili_u_m_trav_lines where  INSTR(line_class,'-$key') limit 10";
					$category_list[$key]=$this->db->query($sql)->result();
				
				}
		//		print_r($category_list);
				return $category_list;
			
			}
			return false;
			//	echo $sql;
			
		}
		
		function get_subclass_list($cateid=0,$begin_record=0,$per_page=10)	//获取子类旅游线路列表
		{
			if((int)$cateid){
				if(!$begin_record){$begin_record=0;}
				$sql="select id,line_tags,line_info,TravelTime,trav_title,price_per,departure_date,tuijian from  dili_u_m_trav_lines  where  INSTR(line_class,'-$cateid,') or INSTR(line_class,',$cateid-') group by id limit $begin_record,$per_page";
				$subclass_list['list']=$this->db->query($sql)->result();

				$sql_annex="select id,name,folder,type from  dili_u_m_trav_lines as l inner join dili_attachments as a on l.id=a.content where ( INSTR(line_class,'-$cateid,') or INSTR(line_class,',$cateid-')) and model=1 group by id limit $begin_record,$per_page";
				$annex=$this->db->query($sql_annex)->result();
				foreach($annex as $item){
					$subclass_list['annex'][$item->id]=$item;
				}
		//	print_r($subclass_list);
		//	exit();
				return $subclass_list;
			}
			return false;
			
			
			
		}	
		
		
		function get_relativelines_list($cateid=1)	//获取相关文章
		{
			$sql="select id,update_time,trav_title,price_per,departure_date,transparency from  dili_u_m_trav_lines inner join dili_u_c_trav_lines on dili_u_c_trav_lines.classid=dili_u_m_trav_lines.line_class where parentid=".$cateid." or classid=".$cateid." limit 5";
			$relativelines_list=$this->db->query($sql)->result();
			return $relativelines_list;
		}				

		
		
		
	}